import { _decorator, Component, Node } from 'cc';
import { EnEvent } from '../Common/const/EnEvent';
import { GameAPI } from '../Common/GameAPI';
const { ccclass, property } = _decorator;

export enum GuideTipType {
    None,
    TreeTip,
    AttackEnemyTip,
    TowerTip,
    HeroTip,
    TowerUpgradeTip,
}

@ccclass('GuideTipController')
export class GuideTipController extends Component {

    @property(Number)
    private tipIndex: number = 1;

    private contentNode: Node = null;
    private isShow: boolean = false;

    start() {
        this.contentNode = this.node.getChildByName("Node");
        GameAPI.RegGEvent(EnEvent.GuideTipEvent, this.OnGuideTipEvent.bind(this), this);
    }

    onDestroy() {
        GameAPI.OffAllCaller(this);
    }

    OnGuideTipEvent(arg) {
        if (arg.index == this.tipIndex) {
            if (arg.active) {
                if (this.isShow) {
                    return;
                }
                this.isShow = true;
            }
            this.contentNode.active = arg.active;
        }
    }

}


